﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;using AllInOne;
using System.IO;

namespace CommunityGuider
{
    class HomePresenter
    {
        IHomePage home;
        String samplePath = @"..\Resources\Samples";

        public HomePresenter(IHomePage home)
        {
            this.home = home;

            home.Render += () => home.LoadSamples();
        }

        internal void Run(string sample)
        {
            var source = File.ReadAllText(Path.Combine(samplePath, sample));

            var cr = Compiler.CompileAndRun(source);

            home.ShowErrors(cr.Errors);
        }
    }
}
